function check_allow() {

	if($("#allow").is(':checked'))
		{
			$("#test_allow").val("true");
			$("#test4").text(' ');
		}
		else
		{
			$("#test_allow").val("false");
			$("#test4").text('请勾选同意');
		}
}
function check_number(){
	var account = document.getElementById("user_number").value;
    var pwd = document.getElementById("user_pwd").value;
    var cpwd = document.getElementById("user_cpwd").value;
  	var phone = document.getElementById("user_phone").value;
  	var submit = 0;
  	
  	if(account.length>=5){
	    $("#test").text("");
	    $("#test_account").val("true");
  	}else{
  		$("#test").text("用户名长度不得低于5");
  		$("#test_account").val("false");
	}

   $.ajax({
	   method:"post",
	   url:"/FAFCode/UserRegister",
	   data:{user_number:account,user_pwd:pwd,user_phone:phone,submit:submit},
	   dataType: "json",
	   success: function(data){
		   if(data.code== 0  ){
		  	   $("#test").text("用户名已存在");
		  	   $("#test_account").val("false");
		   }
		   if(data.code== -1  ){
		  	   $("#test").text("不可使用手机号当作用户名");
		  	   $("#test_account").val("false");
		   }
	   }
  	});
}
function check_pwd(){
	
	var account = document.getElementById("user_number").value;
    var pwd = document.getElementById("user_pwd").value;
    var cpwd = document.getElementById("user_cpwd").value;
  	var phone = document.getElementById("user_phone").value;
  	var submit = 0;
  	
	if(pwd.length>=5){
	    $("#test5").text("");
	    $("#test_pwd").val("true");
	}else{
	    $("#test5").text("密码长度不得低于5");
	    $("#test_pwd").val("false");
	}
}
function check_cpwd(){
	
	var account = document.getElementById("user_number").value;
    var pwd = document.getElementById("user_pwd").value;
    var cpwd = document.getElementById("user_cpwd").value;
  	var phone = document.getElementById("user_phone").value;
  	var submit = 0;
	if(pwd==cpwd){
	   $("#test2").text("");
	   $("#test_cpwd").val("true");
	}else{
	   $("#test2").text("两次密码输入不一致");
	   $("#test_cpwd").val("false");
	}
  }
function check_phone(){
  	var account = document.getElementById("user_number").value;
    var pwd = document.getElementById("user_pwd").value;
    var cpwd = document.getElementById("user_cpwd").value;
  	var phone = document.getElementById("user_phone").value;
	var submit = 0;
  	$.ajax({
	   method:"post",
	   url:"/FAFCode/UserRegister",
	   data:{user_number:account,user_pwd:pwd,user_phone:phone,submit:submit},
	   dataType: "json",
	   success: function(data){
		   if(data.code== -2  ){
		  	   $("#test3").text("请使用正确的手机号");
		  	   $("#test_phone").val("false");
		   }
		   else{
			   $("#test3").text("");
			   $("#test_phone").val("true");
		   }
	   }
  	});
}
function check(){
	
	var account = document.getElementById("user_number").value;
    var pwd = document.getElementById("user_pwd").value;
    var cpwd = document.getElementById("user_cpwd").value;
  	var phone = document.getElementById("user_phone").value;
  	
  	var account_check = document.getElementById("test_account").value;
	var pwd_check = document.getElementById("test_pwd").value;
	var phone_check = document.getElementById("test_phone").value;
	var cpwd_check = document.getElementById("test_cpwd").value;
	var allow_check = document.getElementById("test_allow").value;

    if(pwd_check=="true"&&cpwd_check=="true"&&phone_check=="true"&&account_check=="true"&&allow_check=="true"){//输入密码一致后 */
	   	 $.ajax({
		   method:"post",
		   url:"/FAFCode/UserRegister",
		   data:{user_number:account,user_pwd:pwd,user_phone:phone,submit:"1"},
		   dataType: "json",
		   success: function(data){
			   if(data.code== "1"  ){
			  	 $("#test").text("注册成功");
			  	 submit();
			  	 setTimeout("turn();",1500);
			   }
		   },
		   error: function(data){
			   alert("出现了点小问题请等待一下");
		   }
		   
	  	});
    }
    else{
    	error();
    }
}
function submit(){
	swal({
	    title: "成功",
	    text: "注册成功",
	    type: "success",
	    showConfirmButton: false
	 });
}
function error(){
	 swal({
         title: "错误",
         text: "请检查注册信息！",
         type: "error",
         confirmButtonColor: "#DD6B55",
         closeOnConfirm: false
     });
}
function turn(){
	 window.location.href="login.jsp"; 
}